
indonesia_scores <-
  read.csv("./_3_data/indonesia_test_scores.csv") %>%
  select(-X) %>%
  left_join(., indonesia_data %>% select(town_code, pop)) %>%
  mutate(country = "Indonesia") %>%
  ggplot(aes(x=log10(pop), y = un_score_sma)) +
  geom_point(color="darkgrey", shape = 21, alpha = 0.5) + 
  geom_smooth(method = "lm", color = "black") +
  stat_summary_bin(fun='mean', bins=20,
                   shape = 21, fill = "lightgrey",
                   color='black', size=2.5, geom='point') +
  theme_bw() +
  scale_colour_grey() +
  scale_x_continuous(limits = c(4.5, 6.5)) +
  theme(panel.grid.minor = element_blank(), 
        panel.grid.major.x = element_blank(),
        axis.line.y.left = element_blank(),
        legend.position = "bottom",
        strip.background = element_blank(),
        legend.title = element_blank(),
        axis.line = element_line(colour = "black"),
        panel.border = element_blank(),
        axis.ticks.y = element_blank(),
        axis.title.y = element_blank()) +
  xlab("Population, log scale") +
  ggtitle("National Test Scores (2015)")

ggsave("./_4_outputs/figure_oa_vii.pdf", plot = indonesia_scores, width = 5, height = 2.5)


